<template>
      <div>
         {{$route.params.id}}
         <div>
             <span>{{detail.title}}</span>
             <img :src="detail.url" alt="">
             <span>{{detail.price}}</span>
             <button @click="addShop(detail.id)">加入购物车</button>
             <span>{{detail.num}}</span>
         </div>
      </div>
</template>

<script>
import {mapMutations,mapState} from "vuex"
export default {
    methods:{
        ...mapMutations(['setDetail',"addShop1"]),
        addShop(id){
            this.addShop1(id)
        }

    },
    mounted(){
        this.setDetail(this.$route.params.id)
    },
    computed:{
        ...mapState(["detail"])
    }
}
</script>

<style>

</style>